package com.baidu.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baidu.entity.PageResult;
import com.baidu.mapper.DietarylibraryMapper;
import com.baidu.pojo.Dietarylibrary;
import com.baidu.pojo.Sports;
import com.baidu.service.DietarylibraryService;
import com.baidu.service.SportsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;

@Service(interfaceClass = DietarylibraryService.class)
public class DietarylibraryServiceImpl implements DietarylibraryService {
    @Autowired
    DietarylibraryMapper dietarylibraryMapper;

    @Override
    public Dietarylibrary findDietarylibraryById(Integer id) {
        return dietarylibraryMapper.findDietarylibraryById(id);
    }

    @Override
    public PageResult findByPage(Integer currentPage, Integer pageSize, String queryString) {
        PageHelper.startPage(currentPage,pageSize);
        Page<Dietarylibrary> page=dietarylibraryMapper.findByPage(queryString);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void addDietarylibrary(Dietarylibrary dietarylibrary) {
        dietarylibraryMapper.addDietarylibrary(dietarylibrary);
    }

    @Override
    public void editDietarylibrary(Dietarylibrary dietarylibrary) {
        dietarylibraryMapper.editDietarylibrary(dietarylibrary);
    }

    @Override
    public void deleteDietarylibraryById(Integer id) {
        dietarylibraryMapper.deleteDietarylibrary(id);
    }
}
